package driver.ui.driver.Adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import driver.ui.R;
import driver.ui.driver.Beans.action;


public class ActionlistAdapter extends ArrayAdapter<action>{

	int resource;
    String response;
    Context context;
    //Initialize adapter
    public ActionlistAdapter(Context context, int resource, List<action> items) {
        super(context, resource, items);
        this.resource=resource;
 
    }
 
    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        LinearLayout setupView;
        //Get the current alert object
        action ac = getItem(position);

 
        //Inflate the view
        if(convertView==null)
        {
            setupView = new LinearLayout(getContext());
            String inflater = Context.LAYOUT_INFLATER_SERVICE;
            LayoutInflater vi;
            vi = (LayoutInflater)getContext().getSystemService(inflater);
            vi.inflate(resource, setupView, true);
        }
        else
        {
            setupView = (LinearLayout) convertView;
        }
        //Get the text boxes from the actionitems.xml file
        ImageView actionImg =(ImageView)setupView.findViewById(R.id.actionimg);
        actionImg.setImageResource(ac.getImgsrc());
        TextView actionName =(TextView)setupView.findViewById(R.id.actionname);
        actionName.setText(ac.getName());
     
        return setupView;
        
    }
}
